package com.zk.shop.controller;

import com.github.pagehelper.PageInfo;
import com.zk.shop.pojo.Menu;
import com.zk.shop.service.MenuService;
import com.zk.shop.util.RespUtil;
import com.zk.shop.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/menu")
public class MenuController {

    @Autowired
    MenuService menuService;

    @RequestMapping("/menuList/{page}/{size}")
    @ResponseBody
    public Result getAllMenu(@PathVariable("page")Integer page,@PathVariable("size") Integer size){
        System.out.println(page+"-"+size);
        try{
            List<Menu> list = menuService.getAllMenu(page,size);
            PageInfo<Menu> p = new PageInfo<>(list);
            return new RespUtil().POK("200","查询成功",true,p);
        }catch(Exception e){
            return new RespUtil().MOK("000000","[/future/menu/menuList]接口异常:"+e.getStackTrace().toString(),false);
        }
    }


}
